﻿// stdafx.h: 标准系统包含文件的包含文件，
// 或是经常使用但不常更改的
// 项目特定的包含文件
//

#pragma once


namespace DuiLib
{
	class CChatContextViewUI : public CAbstractItemView,
								public CVerticalLayoutUI
	{
	public:
		DECLARE_DUICONTROL(CChatContextViewUI)

		enum {
			Column_Name = 0,
			Column_Icon,
			Column_Text,
			Column_Flag,
		};
	public:
		CChatContextViewUI();
		~CChatContextViewUI();

		LPCTSTR GetClass() const;
		LPVOID GetInterface(LPCTSTR pstrName);

		virtual void setModel(CAbstractItemModel* pModel);

		void setItemSource(const CDuiString& itemSource);

	protected Dui_Slots:
		virtual void onDataChanged(const CModelIndex& index,
			const CVar& oldValue, const CVar& newValue);

		virtual void onRowsBefroreInsert(int row, int count, const CModelIndex& parent);
		virtual void onRowsInserted(int row, int count, const CModelIndex& parent);

		virtual void onRowsBefroreRemove(int row, int count, const CModelIndex& parent);
		virtual void onRowsRemoved(int row, int count, const CModelIndex& parent);

		virtual void onRemoveAll(int rowCount);

	private:
		void showModel();

		CContainerUI* getItemContainer(int row);

		void setItemData(CModelIndex index);
		void setItemName(CModelIndex index, const CDuiString& text);
		void setItemIcon(CModelIndex index, const CDuiString& text);
		void setItemText(CModelIndex index, const CDuiString& text);
		void selectItemShow(CModelIndex index, int flag);

		CControlUI* addLineToView();
		

		void OnSetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);

		int m_ColumnCount;

		CDuiString m_ItemSource;
	};

}
